﻿@using TaskoMask.BuildingBlocks.Contracts.Dtos.Tasks
@using TaskoMask.Clients.UserPanel.Pages.Tasks.Components
@inject TaskoMask.Clients.UserPanel.Services.DragDrop.IDragDropService DragDropService

@foreach (var item in Model)
{
    <a @onclick="@(()=>ShowDetailsModal(item.Id))" class="text-black">
        <div class="rounded p-3 mb-2 mx-1 task-item" draggable="true" ondragstart="@(() => HandleDragStart(item.Id))">
            @item.Title
        </div>
    </a>
}




@code {

    [Parameter]
    public IEnumerable<GetTaskDto> Model { get; set; }

    [Parameter]
    public string CardId { get; set; }




    /// <summary>
    ///
    /// </summary>
    private void ShowDetailsModal(string taskId)
    {
        var parameters = new ModalParameters();
        parameters.Add(nameof(Pages.Tasks.Components.Details.TaskId), taskId);
        ModalService.Show<Pages.Tasks.Components.Details>("", parameters, new ModalOptions { Class = "blazored-modal w-100 h-100  bg-light-gray" });
    }



    /// <summary>
    ///
    /// </summary>
    private void HandleDragStart(string taskId)
    {
        DragDropService.SetDraggedData(taskId);
    }



}
